home *** CD-ROM | disk | FTP | other *** search
/ CD Concept 6 / CD Concept 06.iso / mac / UTILITAIRE / RLaB / testmatrix / signm.r < prev    next >
Text File  |  1994-12-20  |  1KB  |  45 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    Matrix sign decomposition.
  4.  
  5. // Syntax:    SL = signm ( A )
  6.  
  7. // Description:
  8.  
  9. //    SL is a list containig elements S and N. SL contains the
  10. //    matrix sign decomposition A = S*N,  computed via the Schur
  11. //    decomposition. S is the matrix sign function, sign(A).
  12.  
  13. //      Reference:
  14. //      N.J. Higham, The matrix sign decomposition and its relation to
  15. //      the polar decomposition, Numerical Analysis Report No. 225,
  16. //      University of Manchester, England, April 1993;
  17. //      to appear in Linear Algebra and Appl.
  18.  
  19. //    This file is a translation of signm.m from version 2.0 of
  20. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  21. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  22.  
  23. // Dependencies
  24.    require matsignt
  25.  
  26. //-------------------------------------------------------------------//
  27.  
  28. signm = function ( A )
  29. {
  30.   local (N, S, t)
  31.  
  32.   t = schur (A+zeros(size(A))*1j);
  33.   S = t.z * matsignt(t.t) * t.z';
  34.  
  35.   // Only problem with Schur method is possible nonzero 
  36.   // imaginary part when A is real.  
  37.   // Next line takes care of that.
  38.  
  39.   if (!norm(imag(A),"1")) { S = real(S); }
  40.  
  41.   N = S*A;
  42.  
  43.   return << S = S; N = N >>;
  44. };
  45.